package demo1230.董文祥;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket(8888);
        while (true){
            try {
                Socket socket = server.accept();
                InputStream is = socket.getInputStream();
                for (int i = 0; i < 3; i++) {
                    byte [] bs =new byte[1024];
                    int read = is.read(bs);
                    System.out.println(new String(bs,0,read));
                }

                OutputStream os = socket.getOutputStream();
                os.write("收到了!!".getBytes());
                socket.close();

            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
